package net.lzzy.practicesapi1.entities;

import lombok.Getter;
import lombok.Setter;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @author lyz
 */
@Entity
@Getter
@Setter
public class User extends BaseEntity{
    @Transient
    public static final int TYPE_BANNED =-1;
    @Transient
    public static final int TYPE_ADMIN =0;
    @Transient
    public static final int TYPE_TEACHER =1;
    @Transient
    public static final int TYPE_STUDENT =2;
    private String nickName;
    private String userName;
    private String email;
    private String phone;
    private String password;
    private String avatar;
    private String salt;
    private int type;
    private boolean applyTeacher;
    @Temporal(TemporalType.TIMESTAMP)
    private Date createTime;
    @Temporal(TemporalType.TIMESTAMP)
    private Date updateTime;
    @OneToMany(mappedBy = "teacher")
    private List<Course> courses = new ArrayList<>();
    @ManyToMany(mappedBy = "students")
    private List<Course> enrolledCourse = new ArrayList<>();
    public User(){
        createTime = new Date();
        updateTime = createTime;
    }

}
